/* @INLINE FILE tool_panel.bloc.js =============================================================
	* Tool panels
	* 
	* VAR
	* tmc
	* tool_panel_type
	* 
	* FUNC
	* this.tgl_tools
	* this.create_tool_panel
	* this.fill_tool_panel
	* this.create_tool_panel_backing
    * close_tools
	*/
	
	 var tool_panel_type = null;
    // tmc - tools menu controller
    var tmc;
    this.tgl_tools = function(typ,width, height,fromDialog) {
        var href = "fc_tools";
        var y_offset=_t.smYOffset+(typ==0?0:main_panel.tools_panel.smileys.height-main_panel.tools_panel.icons.height);
        var x_offset=smXOffset;
        if(fromDialog){
        	y_offset=jQ("#fc_e_sml2a").offset().top - main_panel.tools_panel.smileys.height-10;
        	x_offset=jQ("#fc_e_sml2a").offset().left - Math.floor(main_panel.tools_panel.smileys.width/2)+5;
        }
        var overflow=(typ==0?"auto":"hidden");
        _t.tPC = $(href);
        if (_t.tPC != null) {
        	tmc.target.removeEventHandler('mousedown');
        	tmc.target=jQ("a.fc_tools_a");
        	tmc.target.onEvent('mousedown', tmc, 'mouseOn', '');
        	tmc.enableControl();
            if (_t.tPC.style.display == _n || (typ!=null&&typ != tool_panel_type)) {
            	tool_panel_type= typ;
            	tools_panel.style.width=width+'px';
            	tools_panel.style.height=height+'px';
            	tools_panel.style.overflow=overflow;
            	tools_panel[_i]=fc_chat.fill_tool_panel(typ,width,height,fromDialog);
            	if(fromDialog){
            		_t.tPC.style.position=jQ("#fc_quickchat").css("position");
                	document.body.appendChild(_t.tPC);
                }else{
                	_t.tPC.style.position="absolute";
                	chat_panel.appendChild(_t.tPC);
                }
                move_box(_t.tPC, x_offset, y_offset);
                _t.tPC.style.display = _b;
                if (exp6) {
                	_t.tPB.style.width=width+'px';
                	_t.tPB.style.height=height+'px';
                	if(fromDialog){
                		_t.tPB.style.position=jQ("#fc_quickchat").css("position");
                    	document.body.appendChild(_t.tPB);
                    }else{
                    	_t.tPB.style.position="absolute";
                    	chat_panel.appendChild(_t.tPB);
                    }
                    move_box(_t.tPB, x_offset, y_offset);
                    _t.tPB.style.display = _b;
                }
                sO = true;
            } else {
                sO = false;
                _t.tPC.style.display = _n;
                if (exp6) {
                    _t.tPB.style.display = _n;
                }
            }
            if(!fromDialog){
            	return false;
            }else{
            	return;
            }
        }
        tool_panel_type= typ;
        var sDArray=fc_chat.create_tool_panel(href,width,height,overflow,z_b,exp6);
        _t.tPC = sDArray[0];
        tools_panel = sDArray[1];
        tools_panel[_i]=fc_chat.fill_tool_panel(typ,width,height,fromDialog);
        if(fromDialog){
    		_t.tPC.style.position=jQ("#fc_quickchat").css("position");
        	document.body.appendChild(_t.tPC);
        }else{
        	_t.tPC.style.position="absolute";
        	chat_panel.appendChild(_t.tPC);
        }
        move_box(_t.tPC, x_offset, y_offset);
        if (exp6) {
            _t.tPB=fc_chat.create_tool_panel_backing(z_b,tools_panel);
            if(fromDialog){
            	_t.tPB.style.position=jQ("#fc_quickchat").css("position");
            	document.body.appendChild(_t.tPB);
            }else{
            	_t.tPB.style.position="absolute";
            	chat_panel.appendChild(_t.tPB);
            }
            move_box(_t.tPB, x_offset, y_offset);
        }
        if(tmc){
        	tmc.disableControl();
        }
        tmc = new jGo.DefaultMenuController('fc_tools','a.fc_tools_a',_t.tPC,fc_chat,'tgl_tools');
        sO = true;
        setTimeout("fc_chat.change_Border_sD(false)", 200);
        if(!fromDialog)return false;
    };
    this.create_tool_panel = function(href,width,height,overflow,z_b,exp6){
    	var sD = this.tool_menu = document.createElement('div');
    	sD.setAttribute('id', href);
        var _sho = (!exp6)?'jGo_ydsf':'';
        var _shoi = (!exp6)?'jGo_inner':'';
        sD.className = 'jGo_app jGo_myapp '+_sho;
        if(exp6){
        	sD.style.position='absolute';
        }
        sD.style.display = _b;
        sD.style.zIndex = jGo.config.max_z_index - 91;
        var sD2 = document.createElement('div');
        sD2.className = _shoi;
        sD2.style.width = width + 'px';
        sD2.style.height = height + 'px';
        sD2.style.zIndex = jGo.config.max_z_index - 91;
        sD2.style.border = main_panel.tools_panel.border;
        sD2.style.backgroundColor = main_panel.tools_panel.background_color;
        sD2.style.overflow = overflow;
        sD.appendChild(sD2);
        jQ(sD2).css({'-moz-border-radius': '5px','-webkit-border-radius': '5px','border-radius':'5px'});
        return [sD,sD2];
    };
    this.fill_tool_panel = function(typ,width,height,fromDialog){
    	var val = '<center><table style="padding:5px;width:'+(width-5)+'px;height:'+(height-5)+'px;"><tr>';
        var columns = 0;
        if(typ==0){ //smileys
	        for (var i = 0; i < config.smileys.length; i ++ ) {
	            val += '<td><a href="javascript:fc_chat.insertTags(\'{{\',\'}}\',\'' + config.smileys[i][1] + '\','+(fromDialog?'2':'1')+');"><img border="0" src="' + config.smileys_dir + config.smileys[i][0] + '"></a></td>';
	            columns ++ ;
	            if (columns == 6 && i < config.smileys.length - 1) {
	                val += '</tr><tr>';
	                columns = 0;
	            }
	        }
	        if (columns != 0) {
	            val += '<td colspan=' + (6 - columns) + '>&nbsp;</td>';
	        }
	        val += '</tr></table></center>';
        }else{
        	var disabled = opac40+";cursor:default";
        	var imgT = (config.upload_images_enabled ? __(27): __(28));
            var avaT = __(29);
        	val+="<td>" +
        	"<a id='fc_imgu' style='margin-left:1px;" + (config.upload_images_enabled?"":disabled) + "' href=\"javascript:void\" onclick=\"return fc_chat.imgFWrapper()\">" +
        		"<img title='" + imgT + "'src='" + _h + "upload_image.png'>" +
    		"</a>" +
    		(config.change_avatar?"<a id='fc_avu' style='margin-left:2px;' href=\"javascript:void\" onclick=\"return fc_chat.avaFWrapper();\">" +
    			"<img title='" + avaT + "'src='" + _h + "add_avatar.png'>" +
    		"</a>":"") +
    		(config.transliteration_enabled?
    		"<a  id='fc_trlit' style='margin-left:2px;' href='javascript:fc_chat.open_trlit(1)'>" +
    			"<img title='" + __(304,"Type in your language") + "' src='" + _h + "google_transliteration.png'>" +
    		"</a>":"") +
    		(config.chatcenter_layout==0&&!fc_chat.nlrm()?"<a title='"+__(295,"doodlepad")+"' id='fc_note' style='margin-left:2px' href='javascript:fc_chat.note(1)'>" +
			"<img src='" + _h + "pencil.png'>" +
			"</a>":"") +
    		//"<a title='"+__(288,"Open your whiteboard")+"' id='fc_whiteboard' style='margin-left:2px' href='javascript:fc_chat.wb(1)'>" +
    		//"<img src='" + _h + "page_white_paintbrush.png'>" +
    		//"</a>" +
    		"<a title='" + __(311,"Share a document") + "' id='fc_doc' style='margin-left:2px;' href='javascript:fc_chat.doc(1)'>" +
    				"<img src='" + _h + "document.png'>" +
    		"</a>" +
    		
    		"</td></tr></table>";
        }
        
        return val;
    };
    this.create_tool_panel_backing = function(z_b,sD){
        var sIF = document.createElement("IFRAME");
        sIF.className = "jGo_app jGo_myapp";
        sIF.style.position = 'absolute';
        sIF.style.scrolling = 'no';
        sIF.style.zIndex = z_b + 1900;
        sIF.style.width = sD.style.width;
        sIF.style.height = sD.style.height;
        sIF.style.backgroundColor = 'transparent';
        sIF.style.display = _b;
        return sIF;
    };
    
    var close_tools = function(){
		_t.tPC.style.display = _n;
		if (exp6) {
            _t.tPB.style.display = _n;
        }
    };
    
    //tool_panel.bloc.js =============================================================@END FILE*/